# Copyright 2024 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

load(
    "//build_tools/bazel:build_defs.oss.bzl",
    "iree_compiler_cc_library",
    "iree_gentbl_cc_library",
    "iree_tablegen_doc",
)

package(
    default_visibility = ["//visibility:public"],
    features = ["layering_check"],
    licenses = ["notice"],  # Apache 2.0
)

iree_gentbl_cc_library(
    name = "PassesIncGen",
    tbl_outs = [
        (
            ["--gen-pass-decls"],
            "Passes.h.inc",
        ),
    ],
    tblgen = "@llvm-project//mlir:mlir-tblgen",
    td_file = "Passes.td",
    deps = [
        "@llvm-project//mlir:PassBaseTdFiles",
    ],
)

iree_compiler_cc_library(
    name = "VectorExtTransforms",
    srcs = [
        "BufferizationInterfaces.cpp",
        "Passes.cpp",
        "VectorExtFoldUnitExtentDims.cpp",
        "VectorizeIREEVectorExtOps.cpp",
    ],
    hdrs = [
        "BufferizationInterfaces.h",
        "Passes.h",
        "Passes.h.inc",
        "Transforms.h",
    ],
    deps = [
        ":PassesIncGen",
        "//compiler/src/iree/compiler/Codegen/Dialect/VectorExt/IR:IREEVectorExtDialect",
        "//compiler/src/iree/compiler/Dialect/LinalgExt/IR",
        "//compiler/src/iree/compiler/Dialect/LinalgExt/Utils",
        "@llvm-project//llvm:Support",
        "@llvm-project//mlir:ArithDialect",
        "@llvm-project//mlir:BufferizationDialect",
        "@llvm-project//mlir:BufferizationInterfaces",
        "@llvm-project//mlir:BufferizationTransforms",
        "@llvm-project//mlir:FunctionInterfaces",
        "@llvm-project//mlir:IR",
        "@llvm-project//mlir:LinalgDialect",
        "@llvm-project//mlir:LinalgTransforms",
        "@llvm-project//mlir:Pass",
        "@llvm-project//mlir:Support",
        "@llvm-project//mlir:TensorDialect",
        "@llvm-project//mlir:TransformUtils",
        "@llvm-project//mlir:Transforms",
        "@llvm-project//mlir:UBDialect",
        "@llvm-project//mlir:VectorDialect",
        "@llvm-project//mlir:VectorTransforms",
        "@llvm-project//mlir:VectorUtils",
    ],
)

iree_tablegen_doc(
    name = "CodegenDialectVectorExtPassesDocGen",
    category = "Passes",
    tbl_outs = [
        (
            [
                "--gen-pass-doc",
            ],
            "CodegenDialectVectorExtPasses.md",
        ),
    ],
    tblgen = "@llvm-project//mlir:mlir-tblgen",
    td_file = "Passes.td",
    deps = [
        "@llvm-project//mlir:PassBaseTdFiles",
    ],
)
